<script setup>
import {ref} from "vue";

//定义响应变量用来保存计算的数字与结果
const a = ref('');
const b = ref('');
const result = ref('');
//定义函数用来计算
const calc = (o)=>{
  result.value = eval(a.value+o+b.value);
}
</script>

<template>
  <input type="text" placeholder="请输入第一个数字" v-model="a"> <br>
  <input type="text" placeholder="请输入第二个数字" v-model="b"> <br>
  <button @click="calc('+')">加</button>
  <button @click="calc('-')">减</button>
  <button @click="calc('*')">乘</button>
  <button @click="calc('/')">除</button>
  <h3>运算结果:{{result}}</h3>
</template>

<style scoped>

</style>